import csv

myTF1 = []
myTF2 = []

with open("RegulationTwoColumnTable_Documented_2013927.tsv") as tsv:
    for line in csv.reader(tsv, delimiter=";"):
        myTF1.append(line[0])
        myTF2.append(line[1])


# CREATING A SET TO FIND UNIQUE myTF1 ELEMENTS
x = set(myTF1)
uniqTF1 = []
for p in x:
	uniqTF1.append(p)

# FINDING INTERNAL LINKS
out = []
for i in range(len(myTF2)):
	for k in range(len(uniqTF1)):
		if (myTF2[i] == uniqTF1[k]):
			out.append(myTF1[i]+' > '+myTF2[i])

# SORTING, COUNTING, PRINTING
out.sort()
count = 0
for i in out:
	print i
	count += 1

print count
